<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>助力好友 达成心愿</title>
    <link rel="stylesheet" href="../themes/mall/default/styles/share/css/hui.css">
    <link rel="stylesheet" href="../themes/mall/default/styles/share/css/style.css">
    <script src="/mobile/themes/mall/default/styles/share/js/com.js"></script>
    <script src="/mobile/themes/mall/default/styles/share/js/hui.js"></script>
    <script src="/mobile/themes/mall/default/styles/share/js/template-web.js"></script>
    <script src="//cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <style type="text/css">
        .clear:after{clear: both;content:'';display: block;}
        .fl{float: left;}
        .fr{float: right;}

        #youzhi{position: relative;}
        #youzhi:after{content:'';display: block;width: 8px;height: 8px;background: #fff;border:1px solid #666;box-shadow: 0 0 4px #666;position: absolute;right: 0;top: -1px;border-radius: 50%;}
    </style>
</head>
<body>
<div style="background: url(/mobile/themes/mall/default/styles/share/img/back18.png) no-repeat center center;background-size: cover" class="w100per h100per" id="bgcontain">
    <div style="padding: 12px 0 0 18px">
    </div>

    <div id="contain"></div>
</div>

<script type="text/html" id="tpl">
    <div class="fs14 c333 txt_center" style="">
    </div>
    <div class="pad_l10 pad_r10 pad_b16">
        <div class="bdr8 pad_l10 pad_r10 bgcfff bd_allred">
            <div class="bd_b" style="padding: 14px 0;line-height: 28px; height:auto;">
                <div style="height: 650px;">
                    <div style="width:100%; height:100px; text-align:center; line-height:100px; border-bottom:#DADADA solid 1px;">
                        <p style="font-size: 25px">心愿单已取消</p>
                    </div>
                    <div style="width: 100%;height: 240px;padding-top: 93px;">
                        <img style="width:100px;height: 73px;margin-left: 25px;margin-top: -63px;" src="../{$info.goodsSpecInfo.spec_1}" alt="">
                        <div style="position: absolute;float: right;margin: -90px 28px 0 150px;">
                            <font style="width:322px;height:90px;font-size:16px;font-family:PingFang SC;font-weight:400;line-height:1px;
color:rgba(0,0,0,1);">{$info.goodsInfo.goods_name}</font>
                        </div>
                        <div style="position: absolute;float: right;margin: -30px -38px 0 150px;">
                            <font style="width:385px;height:37px;font-size:14px;font-family:PingFang SC;font-weight:400;line-height:36px;color:rgba(153,153,153,1);opacity:1;">{$info.goodsSpecInfo.spec_1value} {$info.goodsSpecInfo.spec_2}</font>
                        </div>
                        <div style="position: absolute;float: right;margin: -7px -38px 0 150px;">
                            <font style="width:385px;height:37px;font-size:14px;font-family:PingFang SC;font-weight:400;line-height:36px;color:rgba(153,153,153,1);opacity:1;">商品售价：￥{$info.goodsSpecInfo.price}</font>


                        </div>
                        <hr style="position: absolute;margin-top:80px;width:90%;height:0px;border:#DADADA solid 1px;"/>

                    </div>
                    <!--<hr style="float:left;width:20%;border:4px solid #ef4f4f;border-radius:8px;margin-top: 46px;margin-left: 55px;"/>-->
                    <!--<hr style="float:left;width:50%;border:4px solid #ef4f4f;border-radius:8px;margin-top: 46px;"/>-->

                </div>

            </div>

        </div>
    </div>
</script>
<script>

    $(function () {
        // 页面加载完毕获取图片的宽度和高度
        $(window).load(function () {
            let w = $('#help_img').width();
            let h = $('#help_img').height();

            $('#help_p').css({
                "width": w + 'px',
                "height": w + 'px',
                "line-height": h + 'px',
                'left': 0,
            });
        });
    });
    //倒计时 start
    var endtime=new Date("{$end_time}");//截止时间
    var timer=setInterval(function(){
        var currtime=new Date();
        var shijiancha=parseInt(endtime-currtime)/1000;
        if(shijiancha>0){
            var days = Math.floor(shijiancha / (60 * 60 * 24));//天数
            var modulo = shijiancha % (60 * 60 * 24);//取模（余数）
            var hours = Math.floor(modulo / (60 * 60));//小时数
            modulo = modulo % (60 * 60);
            var minutes = Math.floor(modulo / 60);//分钟
            var seconds = Math.floor(modulo % 60);//秒
            $('#tian').html(one2two(days));
            $('#shi').html(one2two(hours));
            $('#fen').html(one2two(minutes));
            $('#miao').html(one2two(seconds));
        }else{
            clearInterval(timer);
            timer=null;
        }
    },1000);
    function one2two(num){
        return num<10?'0'+num:num;
    }
    //倒计时 end

    var canajax=true;

    // if(!Getvariable('token') || !Getvariable('goods_id')){
    // 	hui.toast('少token参数/goods_id参数');
    // }else {
    //     pre_loading_txt(0);
    // }

    var data={
        tel:'',
        code:''
    };
    function renderhtml(){
        document.getElementById('contain').innerHTML=template('tpl', data);
    }
    data.tel=Getvariable('phone');
    renderhtml();
    pre_loading_txt(100);
    // }

    //防止 键盘弹出后 背景错位
    var h=window.innerHeight<500?500:window.innerHeight;
    document.getElementById('bgcontain').style.height=h+'px';

    //发送验证码
    var sendmaobj=document.getElementById('sendma');

    var sign = '';
    function sendmafun(){
        if(!canajax){
            return false;
        }

        if(sendmaobj.innerHTML=='发送验证码' || sendmaobj.innerHTML=='重新发送'){
            var phone=document.getElementsByName('phone')[0].value;
            var confirm_password=document.getElementsByName('confirm_password')[0].value;
            var password=document.getElementsByName('password')[0].value;
            if(phone==''){
                hui.toast('请输入手机号');
                return false;
            }
            if(!/^1[3|4|5|7|8]\d{9}$/.test(phone)){
                hui.toast('手机号不正确');
                return false;
            }

            if(password == ''){
                hui.toast('请输入密码');
                return false;
            }
            if(confirm_password == ''){
                hui.toast('请输入确认密码');
                return false;
            }
            if (password == null || password.length < 8) {
                hui.toast('密码长度不足8位');
                return false;
            }
            var reg = new RegExp(/^(?![^a-zA-Z]+$)(?!\D+$)/);
            if (!reg.test(password)){
                hui.toast('密码必须包含数字和字母');
                return false;
            }
            if(password != confirm_password){
                hui.toast('两次密码不一致');
                return false;
            }

            //发送短信接口
            hui.post(
                'index.php?app=share&act=send_messages',
                {
                    mobile:phone,
                },
                function(res){
                    canajax=true;
                    res = JSON.parse(res);
                    if (res.code == 1) {
                        sign = res.result.msg_sign;
                        daojishi();
                    } else
                        hui.toast(res.message);
                    toLogin();
                },
                function(res){
                    canajax=true;
                    console.log('error');
                    console.log(res);
                }
            );
        }
    }
    var timer=null;
    var timezhi=60;
    var timecurr=timezhi;
    function daojishi(){
        console.log('enter')
        timecurr=timezhi;
        sendmaobj.innerHTML=timecurr+'s';

        timer=setInterval(function(){
            if(timecurr>1){
                timecurr--;
                sendmaobj.innerHTML=timecurr+'s';
            }else{
                clearInterval(timer);
                timer=null;
                sendmaobj.innerHTML='重新发送';
            }
        },1000);
    }

    //注册
    function submit(){
        if(!canajax){
            return false;
        }
        var phone=document.getElementsByName('phone')[0].value;
        var password=document.getElementsByName('password')[0].value;
        var confirm_password=document.getElementsByName('confirm_password')[0].value;
        var yzm=document.getElementsByName('yzm')[0].value;

        if(phone==''){
            hui.toast('请输入手机号');
            return false;
        }
        if(!/^1[3|4|5|7|8]\d{9}$/.test(phone)){
            hui.toast('手机号不正确');
            return false;
        }

        if(password == ''){
            hui.toast('请输入密码');
            return false;
        }
        if(confirm_password == ''){
            hui.toast('请输入确认密码');
            return false;
        }
        if (password == null || password.length < 8) {
            hui.toast('密码长度不足8位');
            return false;
        }
        var reg = new RegExp(/^(?![^a-zA-Z]+$)(?!\D+$)/);
        if (!reg.test(password)){
            hui.toast('密码必须包含数字和字母');
            return false;
        }
        if(password != confirm_password){
            hui.toast('两次密码不一致');
            return false;
        }
        if(yzm==''){
            hui.toast('请输入短信验证码');
            return false;
        }

        canajax=false;
        var chuan={
            phone:phone,
            code:yzm,
            password:password,
            confirm_password:confirm_password,
            msg_sign:sign,
            city:city,
            token:Getvariable('token')
        };
        hui.post(
            'index.php?app=share&act=shareRegister',
            chuan,
            function(res){
                canajax=true;
                res = JSON.parse(res);
                if (res.code == 1) {
                    hui.toast('注册成功啦，请赶紧下载APP吧');
                } else if (res.code == -1) {
                    hui.toast(res.msg);
                }
            },
            function(res){
                canajax=true;
                console.log('error');
                console.log(res);
            }
        );
    }
</script>
</body>
</html>